/*************************************************************************
 * TinySG, Copyright (C) 2007, 2008  J.D. Yamokoski
 * All rights reserved.
 * Email: yamokosk at gmail dot com
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of the License,
 * or (at your option) any later version. The text of the GNU Lesser General
 * Public License is included with this library in the file LICENSE.TXT.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the file LICENSE.TXT for
 * more details.
 *
 *************************************************************************/
/*
 * MeshImport.cpp
 *
 *  Created on: Dec 11, 2008
 *      Author: yamokosk
 */

#include "MeshImport.h"
#include "TriMesh.h"

namespace obrsp
{

namespace mesh
{

TriMesh* createTriMesh(const std::string& filename, float sx, float sy, float sz, std::string& errmsg)
{
	int pos = filename.find_last_of(".");
	std::string extension = filename.substr(pos+1);

	// Create a new TriMesh object
	if (!extension.compare("obj")) {
		return importOBJ(filename, sx, sy, sz, errmsg);
	} else if (!extension.compare("stl")) {
		return importSTL(filename, sx, sy, sz, errmsg);
	} else {
		errmsg = "Unsupported file extension.";
		return NULL;
	}
}


} // namespace

} // namespace
